from problem import Problem
import xlrd, xlwt


work = xlrd.open_workbook('xxx.xls') # 输入文件必为.xls
sheet = work.sheet_by_index(0)
head = sheet.row_values(0)
print(head) # ['序号', '一级纲要', '题型', '题干', '选项', '答案']

for i in range(sheet.nrows):
    if i == 0:
        continue
    rowContent = sheet.row_values(i)
    Problem(stem=rowContent[head.index('题干')], # 必选参数
    option=rowContent[head.index('选项')].split('|'), # 假设|为选项分隔符，option为必选参数
    ans=rowContent[head.index('答案')], # 必选参数
    type=rowContent[head.index('题型')],  # 可选参数
    chapter=rowContent[head.index('章节')])  # 可选参数

Problem.write() # 默认输出为output.xls



